<#-- 生成Controller -->
package ${moduleName}.controller;

import ${moduleName}.entity.po.${tableInfo.firstUpperCase}Entity;
import ${moduleName}.service.${tableInfo.firstUpperCase}Abstract;
import com.github.sxtx.common.sys.vo.ResultVo;
import com.github.sxtx.common.sys.PageHelperSet;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.beanutils.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
* @author auto
* @describe 自动生成
* @dateTime 12/26/2017 6:57 PM
*/
@RestController
@RequestMapping(value = "/mgr/${tableInfo.firstLowerCase}/")
public class ${tableInfo.firstUpperCase}Controller {

	@Autowired
	private ${tableInfo.firstUpperCase}Abstract ${tableInfo.firstLowerCase}Service;

	/**
	* ${tableInfo.simpleRemark}列表和分页数据
	* @param map 查询对象
	* @param obj
	* @param request
	* @return 分页数据
	*/
	@RequestMapping(value = "/list",method = RequestMethod.POST)
	public ResultVo ${tableInfo.firstLowerCase}List(@RequestBody Map<String, Object> map, ${tableInfo.firstUpperCase}Entity obj, HttpServletRequest request) {
		PageHelperSet.setPage(map);
		try {
			BeanUtils.populate(obj, map);
		} catch (Exception e) {
		}
		{
			 //添加逻辑代码
		}
		ResultVo vo = new ResultVo();
		vo.setData(new PageInfo(${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.select(obj)));
		return vo;
	}


	/**
	* 添加数据${tableInfo.simpleRemark} add
	* @param obj
	* @param request
	*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public ResultVo ${tableInfo.firstLowerCase}Add( @RequestBody ${tableInfo.firstUpperCase}Entity obj, HttpServletRequest request) {
		ResultVo vo = new ResultVo();
		{
			 //添加逻辑代码
		}
		vo.setData(${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.insert(obj));
		return vo;
	}



	/**
	* 数据更新${tableInfo.simpleRemark} update
	* @param obj
	* @param request
	*/
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public ResultVo ${tableInfo.firstLowerCase}Update( @RequestBody ${tableInfo.firstUpperCase}Entity obj, HttpServletRequest request) {
		ResultVo vo = new ResultVo();
		vo.setData(${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.updateByPrimaryKey(obj));
		return vo;
	}

	/**
	* 根据参数查询${tableInfo.simpleRemark} delete
	* @param id
	*/
	@RequestMapping(value = "/delete", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultVo ${tableInfo.firstLowerCase}Delete(@RequestParam Integer id){
		ResultVo vo = new ResultVo();

		//TODO 请注意是否逻辑删除 
		//${tableInfo.firstUpperCase}Entity obj = ${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.selectByPrimaryKey(id);
		{
			 //添加逻辑代码
		}
//		TODO 请注意是否逻辑删除
//		vo.setData(numberUserMgrService.numberUserMgrMapper.updateByPrimaryKeySelective(obj);
		vo.setData(${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.delete(new ${tableInfo.firstUpperCase}Entity(){{setId(id);}}));	
		return vo;
	}

	/**
	* 修改前的对象查询${tableInfo.simpleRemark} get
	* @param id
	* @param request
	*/
	@RequestMapping(value = "/get", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultVo ${tableInfo.firstLowerCase}get( @RequestParam Integer id){
		ResultVo vo = new ResultVo();
		vo.setData(${tableInfo.firstLowerCase}Service.${tableInfo.firstLowerCase}Mapper.selectByPrimaryKey(id));
		return vo;
	}

}